/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn;

import java.util.Random;
import java.util.regex.Pattern;

/**
 * <p>Project: app2022 - Ex3
 * <p>Powered by webrx On 2022-01-13 15:16:08
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex3 {
    public static void main(String[] args) {
        Random rand = new Random();
        String[] o = {"","+","-"};
        StringBuilder sbu = new StringBuilder("1");
        while(true) {
            for (int i = 2; i < 9; i++) {
                sbu.append(String.format("%s%d", o[rand.nextInt(o.length)], i));
            }
            sbu.append("9");
            if(is(sbu.toString())){
                System.out.println(sbu.toString() + "=100");
                break;
            }
            sbu.delete(0,sbu.length());
            sbu.append("1");
        }
    }

    public static boolean is(String s){
        boolean f = false;
        var str = Pattern.compile("[+-]?\\d+");
        var m = str.matcher(s);
        int sum = 0;
        while(m.find()){
            sum += Integer.parseInt(m.group());
        }
        if(sum==100) f=true;
        return f;
    }
}
